package com.server.order.controller;

import com.server.common.code.utils.AjaxResult;
import com.server.common.security.code.anntation.Log;
import com.server.common.security.code.anntation.PreAuthorize;
import com.server.model.all.order.bo.PlaceOrderBo;
import com.server.model.all.order.dto.PlaceOrderDto;
import com.server.order.service.TaskOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = "/taskOrder")
public class TaskOrderController {

    @Resource
    private TaskOrderService taskOrderService;


    /**
     * IP下单
     * @author LXC
     * @date 2022/5/2 21:00
     */
    @Log
    @PostMapping("/placeOrder")
    @PreAuthorize(hasPre = "order:taskOrder:placeOrder")
    public AjaxResult placeOrder(@RequestBody PlaceOrderDto placeOrderDto) {
        PlaceOrderBo placeOrderBo= new PlaceOrderBo();
        BeanUtils.copyProperties(placeOrderDto,placeOrderBo);
        taskOrderService.placeOrder(placeOrderBo);
        return AjaxResult.success();
    }

}
